package com.qihoo.finance.fake.module.threadpool.entity;

import java.io.Serializable;

/**
 * 线程池信息
 * Created by zhaoliping on 2016/6/3.
 */
public class ThreadPoolInfoEntity implements Serializable, Cloneable {

    private static final long serialVersionUID = 1L;

    // 线程池名称
    private String name;

    // 所属模块
    private String module;

    // 核心线程数
    private int coreSize = 5;

    // 最大线程数
    private int maxSize = 30;

    // 线程空闲的生存时间。单位：秒
    private long threadKeepAliveTime = 5;

    // 线程池队列的容量
    private int queueSize = 10000;

    /**
     * 策略
     */
    private String policy;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getModule() {
        return module;
    }

    public void setModule(String module) {
        this.module = module;
    }

    public int getCoreSize() {
        return coreSize;
    }

    public void setCoreSize(int coreSize) {
        this.coreSize = coreSize;
    }

    public int getMaxSize() {
        return maxSize;
    }

    public void setMaxSize(int maxSize) {
        this.maxSize = maxSize;
    }

    public long getThreadKeepAliveTime() {
        return threadKeepAliveTime;
    }

    public void setThreadKeepAliveTime(long threadKeepAliveTime) {
        this.threadKeepAliveTime = threadKeepAliveTime;
    }

    public int getQueueSize() {
        return queueSize;
    }

    public void setQueueSize(int queueSize) {
        this.queueSize = queueSize;
    }

    public String getPolicy() {
        return policy;
    }

    public void setPolicy(String policy) {
        this.policy = policy;
    }

    @Override
    public ThreadPoolInfoEntity clone() {
        ThreadPoolInfoEntity obj = new ThreadPoolInfoEntity();
        obj.name = this.name;
        obj.module = this.module;
        obj.coreSize = this.coreSize;
        obj.maxSize = this.maxSize;
        obj.threadKeepAliveTime = this.threadKeepAliveTime;
        obj.queueSize = this.queueSize;
        obj.policy = this.policy;
        return obj;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((name == null) ? 0 : name.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof ThreadPoolInfoEntity)) return false;

        ThreadPoolInfoEntity that = (ThreadPoolInfoEntity) o;

        if (coreSize != that.coreSize) return false;
        if (maxSize != that.maxSize) return false;
        if (threadKeepAliveTime != that.threadKeepAliveTime) return false;
        if (queueSize != that.queueSize) return false;
        if (name != null ? !name.equals(that.name) : that.name != null) return false;
        if (module != null ? !module.equals(that.module) : that.module != null) return false;
        return policy != null ? policy.equals(that.policy) : that.policy == null;
    }

    @Override
    public String toString() {
        return "ThreadPoolInfoEntity{" +
                "name='" + name + '\'' +
                ", module='" + module + '\'' +
                ", coreSize=" + coreSize +
                ", maxSize=" + maxSize +
                ", threadKeepAliveTime=" + threadKeepAliveTime +
                ", queueSize=" + queueSize +
                ", policy='" + policy + '\'' +
                '}';
    }
}
